package com.example.superyi.myteam.fragment;

import androidx.databinding.DataBindingUtil;
import androidx.lifecycle.ViewModelProviders;

import android.content.Intent;
import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.superyi.myteam.R;
import com.example.superyi.myteam.abilitybox.TeamMasterActivity;
import com.example.superyi.myteam.abilitybox.createteams.CreateTeamActivity;
import com.example.superyi.myteam.abilitybox.showteams.ShowTeamsActivity;
import com.example.superyi.myteam.databinding.HomeFragmentBinding;

public class HomeFragment extends Fragment implements View.OnClickListener {

    private HomeViewModel mViewModel;
    private HomeFragmentBinding binding;

    public static HomeFragment newInstance() {
        return new HomeFragment();
    }

    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {
        binding = DataBindingUtil.inflate(inflater,R.layout.home_fragment,container,false);
//        return inflater.inflate(R.layout.home_fragment, container, false);
        return binding.getRoot();
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        mViewModel = ViewModelProviders.of(this).get(HomeViewModel.class);

        binding.BtnBoxMyTeam.setOnClickListener(this);
        binding.BtnBoxCreateTeam.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.BtnBox_MyTeam:
                Intent intentToShowTeamActivity = new Intent(getActivity(), ShowTeamsActivity.class);
                startActivity(intentToShowTeamActivity);
                break;
            case R.id.BtnBox_CreateTeam:
                Intent intentToCreateActivity = new Intent(getActivity(), CreateTeamActivity.class);
                startActivity(intentToCreateActivity);
                break;
            default:
                break;
        }
    }
}
